#include "common.h"

#include <assert.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#include "src/util/log.h"
#include "src/util/rand.h"
#include "tests/common_test.h"

static void rand_init(struct sc_rand *rand) {
    sc_tick seed = 0x123456789ABCDEF; // microsecond precision

    // 用移位的方式初始化一个随机数种子
    rand->xsubi[0] = (seed >> 32) & 0xFFFF;

    assert(seed >> 32 == 0x1234567);
    assert(rand->xsubi[0] == 0x4567);

    rand->xsubi[1] = (seed >> 16) & 0xFFFF;

    assert(seed >> 16 == 0x123456789AB);
    assert(rand->xsubi[1] == 0x89AB);

    rand->xsubi[2] = seed & 0xFFFF;
    assert(rand->xsubi[2] == 0xCDEF);    
}

static void test_rand_init(void){
    struct sc_rand rand;
    rand_init(&rand);

    assert(1 == 1);
}

static void test_sc_rand_u32(void){
    struct sc_rand rand;
    sc_rand_init(&rand);
    uint32_t a = sc_rand_u32(&rand);
    uint32_t b = sc_rand_u32(&rand);
    assert(a != b);
}
 
int main(int argc, char *argv[])
{
    (void)argc;
    (void)argv;

    
    test_rand_init();
    test_sc_rand_u32();

    return 0;
};